package criterioBusqueda;


import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import model.Publicacion.Pregunta;
import model.criterio.criteriosYbusqueda.CriterioDeFecha;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class TestCriterioDeFecha {
	Pregunta p;
	CriterioDeFecha c;

	@Before
	public void setUp() throws Exception {
		c=new CriterioDeFecha(new DateTime(2014, 10, 10, 0, 0,DateTimeZone.UTC));
		p=mock(Pregunta.class);
	}

	@Test
	public void testSeCumple() {
		when(p.getFecha()).thenReturn(new DateTime(2014, 9, 10, 0, 0,DateTimeZone.UTC));
		Assert.assertEquals(true, c.seCumple(p));
		when(p.getFecha()).thenReturn(new DateTime(2014, 11, 10, 0, 0,DateTimeZone.UTC));
		Assert.assertEquals(false, c.seCumple(p));
		verify(p,times(2)).getFecha();
		
	}

}
